<?php
/**
 * Hesperos library for Zend Framework
 *
 * This script is protected by copyright. It's use, copying, modification
 * and distribution without written consent of the author is prohibited.
 *
 * @category    Hesperos
 * @package     Form
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2011 Krzysztof Kardasz
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt  GNU Lesser General Public
 * @version     1.0 $Id$
 * @link        http://code.google.com/p/hesperos/
 */

/**
 * Formularz
 *
 * @category    Hesperos
 * @package     Form
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2011 Krzysztof Kardasz
 * @version     1.0 $Id$
 */
class Hesperos_Form_Form extends Zend_Form
{
    /**
     * Niestandardowe błędy
     *
     * @var null|array
     */
    private $_errors = null;

    /**
     * Zwraca zdefiniowane niestandardowe błędy
     *
     * @return array
     */
    public function getCustomErrors ()
    {
        if($this->_errors == null) {
            $this->_errors = array();
            if($this->isErrors()) {
                foreach($this->getMessages() as $error) {
                    if(!is_array($error)) {
                        $this->_errors[] = $error;
                    }
                }
            }
        }
        return $this->_errors;
    }

    /**
     * Zwraca flagę czy są zdefiniowane niestandardowe błędy
     *
     * @return boolean
     */
    public function hasCustomErrors ()
    {
        $errors = $this->getCustomErrors ();
        return !empty($errors);
    }
}